package conectarBBDD;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class MainOracle {

	public static void main(String[] args) {
		try {
			//comentario de prueba manolo
			Class.forName("oracle.jdbc.OracleDriver");

			String BaseDeDatos = "jdbc:oracle:thin:@81.172.115.164:1521:orcl";  
			
			Connection conexion = null;
			
			conexion = DriverManager.getConnection(BaseDeDatos, "alumno","alumno");  
	        if (conexion != null) { 
	            System.out.println("Conexion exitosa!"); 
	        } else { 
	            System.out.println("Conexion fallida!"); 
	        }

			String query = "SELECT * FROM FAMILIAS";
			
			Statement s = (Statement) conexion.createStatement();
			ResultSet rs = (ResultSet) s.executeQuery(query);

			while (rs.next()) {
				System.out.println(rs.getString(1));
			}
		} catch (Exception e) {
			System.err.println(e.getMessage());
		}

	}

}
